<template>
    <view class="globe_back">
        <view class="box">
			<scroll-view scroll-y="true"  style="height: 500px;">
            <!-- 售后原因 -->
          <!--  <u-picker :show="show" :columns="columns" @confirm="confirm" @cancel="cancel" keyName="title"></u-picker>
            <view class="flex justify_content_between AfterSales">
                <view>售后原因</view>
                <view class="flex" @click="show = true">
                    <input type="text" placeholder="请选择售后原因" disabled="true" v-model="AfterSales" />
                    <u-icon name="arrow-right" size="16"></u-icon>
                </view>
            </view> -->
            <!-- 描述凭证 -->
            <view class="list" style="background-color: #fff;">
                <view class="f_28">意见内容</view>
                <textarea class="f_28 mt_16" name="" id="" cols="30" v-model="describe_credentials" rows="5" placeholder="在这里输入反馈意见"></textarea>
                <view>
					<u-upload
						:fileList="fileList1"
						@afterRead="afterRead"
						@delete="deletePic"
						name="1"
						multiple
						:maxCount="6"
						width="70"
						height="70"
					 >
						<view class="img_add" style="display: inline-block" >
						    <image :src="url + 'updata-img.png'" mode="" style="width: 100%; height: 100%"></image>
						</view>
					</u-upload>
                </view>
				 
            </view>
           
			</scroll-view>
			<view class="addBtn" @click="qx()">提交反馈</view>
        </view>
		
    </view>
</template>

<script>
import { common } from '@/common/serve.js';
export default {
    data() {
        return {
            url: '',
            show: false,
            maxImagesNum: 6,
            images: [],
            columns: [['原因', '原因1', '原因2']],
            AfterSales: '',
			id:0,
			list:'',
			describe_credentials:'',
			fileList1: [],
			t:0,
			scrollTop:0,
			// images:[],
        };
    },
    onShow() {
        this.url = this.baseUrl + this.imgPath;
    },
	onLoad(e) {
		if(e){
			this.id=e.id
			this.t=e.t
		}
	 // this.lists()
	 // this.appealk_list()
	},
    methods: {
		lists(){
			this.$.ajax(1, "POST", "users/service_goods_order", {
					order_id:this.id,
					// lat:39.222,
					// lng:117.333,
				}, (res) => {
					if(res.code==200){
						// this.$.ti_shi(res.msg)
						 this.list=res.data
						 // console.log(res.data.Destination.mobile,'res.datares.datares.data')
						 
					}else{
						this.$.ti_shi(res.msg)
					}
				})
		},
		appealk_list(){
			this.$.ajax(1, "POST", "users/appealk", {}, (res) => {
				// console.log(res)
					if(res.code==200){
						// this.$.ti_shi(res.msg)
						 this.columns=[res.data]
						 
					}else{
						this.$.ti_shi(res.msg)
					}
				})
		},
		qx(){
			let data={
				  // refund_content:this.AfterSales,
				  content:this.describe_credentials,
				  images:this.images.join(','),
				  // order_id:this.id
			    }
			this.$.ajax(1, "POST", "index/add_feedback", data, (res) => {
					if(res.code==200){
						 this.$.ti_shi(res.msg)
						  setTimeout(()=>{
						 	   uni.navigateBack({
								   delta:1
							   })
						  },1000)
						 
					}else{
						this.$.ti_shi(res.msg)
					}
				})
		},
        confirm(e) {
            this.AfterSales = e.value[0].title;
            this.show = false;
        },
        cancel() {
            this.show = false;
        },
        // 删除现场照片
        deletephotos(i) {
            this.images.splice(i, 1);
        },
			// 删除图片
			deletePic(event) {
				this.images.splice(event.index, 1)
				this[`fileList${event.name}`].splice(event.index, 1)
			},
			// 新增图片
			async afterRead(event) {
				// console.log(event);return;
				// 当设置 multiple 为 true 时, file 为数组格式，否则为对象格式
				let lists = [].concat(event.file)
				let fileListLen = this[`fileList${event.name}`].length
				lists.map((item) => {
					this[`fileList${event.name}`].push({
						...item,
						status: 'uploading',
						message: '上传中'
					})
				})
				for (let i = 0; i < lists.length; i++) {
					const result = await this.uploadFilePromise(lists[i].url)
					let item = this[`fileList${event.name}`][fileListLen]
					this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
						status: 'success',
						message: '',
						url: result
					}))
					fileListLen++
				}
			},
			uploadFilePromise(url) {
			
				return new Promise((resolve, reject) => {
					let a = uni.uploadFile({
						url: this.$.ajax_url+'common/upload', // 仅为示例，非真实的接口地址
						filePath: url,
						name: 'file',
						formData: {
							user: 'test'
						},
						success: (res) => {
							
							this.images.push(JSON.parse(res.data).data.url)
							console.log(this.images)
							setTimeout(() => {
								resolve(res.data.data)
							}, 1000)
						}
					});
				})
			},
		
        // 现场照片
        // async instoreImages() {
        //     let images = this.images;
        //     let num = this.maxImagesNum - images.length; //图片长度

        //     const result = await common.chooseImage(num).catch((err) => console.log('chooseImageErrMsg:', err));
        //     const suceessList = (result || []).filter((item) => item.isSuccess === true);
        //     if (suceessList.length > 0) {
        //         suceessList.map((item) => {
        //             images.push(item.path);
        //         });

        //         this.images = images;
        //     }
        // }
    }
};
</script>

<style scoped lang="scss">
.shopImg {
	width: 200rpx;
	height: 200rpx;
	border-radius: 16rpx;
	margin-right: 24rpx;
}
.detailed {
	color: #333a47;
	font-size: 28rpx;
	margin-bottom: 32rpx;
}
.detailedBox {
	background: white;
	border-radius: 16rpx;
	padding: 24rpx;
	margin-top: 24rpx;
}
.box {
    padding: 32rpx;
}
.img_add {
    width: 140rpx;
    height: 140rpx;
}
.storeImg {
    width: 96rpx;
    height: 96rpx;
    border-radius: 16rpx;
    margin-right: 16rpx;
}
.storeTitle {
    color: #00091a;
    font-size: 32rpx;
    margin-bottom: 8rpx;
}
.addBtn {
    width: 686rpx;
    height: 80rpx;
    line-height: 80rpx;
    text-align: center;
    margin: 24px auto;
    position: fixed;
    // bottom: 80rpx;
    left: 4%;
    // margin-left: -343rpx;
    background: #3377ff;
    border-radius: 24rpx;
    color: white;
	// margin-bottom: 60rpx;
}
// .list {
//     border-radius: 24rpx;
//     background: white;
//     padding: 32rpx 24rpx;
//     font-size: 28rpx;
//     margin-top: 24rpx;
//     .listli {
//         padding: 16rpx 0;
//     }
// }
.AfterSales {
    border-radius: 24rpx;
    background: white;
    padding: 32rpx 24rpx;
    font-size: 28rpx;
    margin-top: 24rpx;
}

.list {
    padding: 24rpx;
    border-radius: 24rpx;
    margin-top: 24rpx;

    .round {
        width: 16rpx;
        height: 16rpx;
        border-radius: 50%;
        background: #00091a;
        font-size: 28rpx;
        margin-top: 16rpx;
    }

    .type {
        color: #3377ff;
        font-weight: bold;
    }

    .time {
        color: #ccced1;
    }

    .title {
        width: 90%;
        color: #00091a;
        font-size: 32rpx;
        font-weight: bold;
    }

    .address {
        display: inline-block;
        white-space: nowrap;
        width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .name {
        font-weight: normal;
        color: #333a47;
        margin-right: 24rpx;
    }

    .iphone {
        font-weight: normal;
        color: #999ca3;
    }

    .money {
        text-align: right;
        color: #666b75;
    }

    .money text {
        color: #ff6401;
        font-weight: bold;
        font-size: 32rpx;
    }

    .btn {
        text-align: right;
    }

    .cance {
        width: 160rpx;
        height: 68rpx;
        line-height: 68rpx;
        border-radius: 8rpx;
        color: #666b75;
        text-align: center;
        border: 2rpx solid #ccced1;
        margin-top: 24rpx;
    }

    .buy {
        width: 160rpx;
        height: 68rpx;
        line-height: 68rpx;
        border-radius: 8rpx;
        color: #ffffff;
        text-align: center;
        background: #3377ff;
        margin-left: 24rpx;
        margin-top: 24rpx;
    }
  }
</style>

